#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline LL read()
{
	LL x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
LL n,m,ans;
LL phi(LL x)
{
	LL t=x;
	for(LL i=2;i<=m;++i)
		if(!(x%i))
		{
			t=t/i*(i-1);
			while(!(x%i))x/=i;
		}
	if(x>1)t=t/x*(x-1);
	return t;
}
int main()
{
	n=read();
	m=sqrt(n);
	for(LL i=1;i<=m;++i)
		if(!(n%i))
		{
			ans+=i*phi(n/i)+(n/i)*phi(i);
			if(i*i==n)ans-=i*phi(i);
		}
	printf("%lld\n",ans);
	return 0;
}
